import logging
from redis import StrictRedis


class Config(object):
    DEBUG = True
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information18"
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    REDIS_IP = '127.0.0.1'
    REDIS_PORT = 6379
    REDIS_NUM = 7
    SECRET_KEY = "FGSHFKJDJSLJFKDFHSLKLFMDSKL"
    # 设置Session在哪个数据库
    SESSION_TYPE = 'redis'
    # Session放在redis数据库的配置信息
    SESSION_REDIS = StrictRedis(host=REDIS_IP,port=REDIS_PORT,db=REDIS_NUM)
    #是否加密
    SESSION_USE_SIGNER = True
    # 不设置过期时长
    SESSION_PERMANENT = False
    # 4.session的过期时长
    PERMANENT_SESSION_LIFETIME = 86400 * 2



class DevelopmentConfig(Config):
    """开发者模式"""
    DEBUG = True
    LEVEL_LOG = logging.DEBUG


class ProductionConfig(Config):
    """线上模式"""
    DEBUG = False
    LEVEL_LOG = logging.WARNING



config_dict = {
    "development": DevelopmentConfig,
    "production" : ProductionConfig
}